<?php

/**
 * @author binhlv@gmail.com
 * @copyright 2012
 */
class SiteUtility{
    function setCookie( $key, $value ) {
    		$cookie_domain = $_SERVER['HTTP_HOST'];;
    		$cookie_path = '/';
    		@setcookie( $key, $value, time()+60*60, $cookie_path, $cookie_domain, 0, true);
    		$_COOKIE[ $key ] = $value;
    }
    function getCookie( $key, $valDefault = '') {
     
    		return isset( $_COOKIE[ $key ] ) ? $_COOKIE[ $key ] : $valDefault;
    }   
   function curPageURL() {
     $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     $pageURL = preg_replace('#\?city=(.*)#is','',$pageURL);
     return $pageURL;
    }
}

?>